package mmc.server.shell.ops.utility;

import java.util.Map.Entry;

import mmc.EngineObject;
import mmc.server.Server;
import mmc.server.shell.Shell;
import mmc.server.shell.ShellException;
import mmc.server.shell.ops.Function;

public class Who extends Function {

	public Who(String text) throws ShellException {
		super(text, "who", 0, false);
	}
	
    @Override
    public double execute() {
        throw new RuntimeException(this+" has no return value");
    }
    
    public Object executeComplex(){
    	Shell.out.println("All objects:");
		
		synchronized (Server.instance.getScene()) {
			for(Entry<Integer, EngineObject> entry : Server.instance.getScene().objects.entrySet())
			{
				EngineObject o = entry.getValue();
				Shell.out.println(o.toString());
			}
		}
    	return null;
    }
    
    public Class<?> getOutputType(){
    	return void.class;
    }
	
	public static String getDescription(){
    	return formatHelpString("who()","prints objects on server");
    }
}
